<div id="content">
	<div class="row s_page_title">
		<sa-big-breadcrumbs [items]="['物料跟踪管理','基础信息维护','物料管理']" icon="fa-lg fa-fw fa fa-cubes" class="col-xs-12 col-sm-7 col-md-7 col-lg-4"></sa-big-breadcrumbs>
	</div>
	<sa-widgets-grid>
		<div class="s_table">
			<div sa-widget [editbutton]="false" color="darken" class="clearfix">
				<header><span class="widget-icon"> <i class="fa fa-table"></i> </span><h2>物料管理</h2></header>
				<div>
					<div class="widget-body no-padding">

						<div class="page-header clearfix s_table_opreation">
							<div class="left page-header-btn">
								<div class="top_module top_module_box">
									<span class="top_module_label module_text">产品类型</span>
									<select name="" class="top_module_select" [(ngModel)]="materielType">
										<option value="">全部</option>
										<option *ngFor="let item of materialTypeList" [value]='item.materielType'>
											{{item.materielTypeName}}</option>
									</select>
								</div>
								<div class="top_module cancle">
									<span class="module_text">产品名称</span>
									<input type="text" class="module_inp top_module_select ng-pristine ng-valid ng-touched" placeholder="产品名称" [(ngModel)]='productName '>
									<div class="s_del_icon" (click)='delKey("productName")'>x</div>
								</div>
								<div class="top_module cancle">
									<span class="module_text">物料编码</span>
									<input type="text" class="module_inp top_module_select ng-pristine ng-valid ng-touched" placeholder="物料编码" [(ngModel)]='materielNumber '>
									<div class="s_del_icon" (click)='delKey("materielNumber")'>x</div>
								</div>
								<div class="top_module cancle">
									<span class="module_text">录入人</span>
									<input type="text" class="module_inp top_module_select ng-pristine ng-valid ng-touched" placeholder="录入人" [(ngModel)]='enterMan'>
									<div class="s_del_icon" (click)='delKey("enterMan")'>x</div>
								</div>
								
								<div class="selectDate top_module">
									<table-select-date [notInit]='true' (outerTime)="datePickerSelected($event)" ></table-select-date>
								</div>
								
								<button  type="button"  class="btn btn-primary" (click)="tableSearch()">查询</button>
								<button  type="button"  class="btn btn-primary" (click)="addMaterialCode(addBomCodeModal)">添加物料编码</button>
								<button  type="button"  class="btn btn-primary" (click)="showImportModal(weightModal)">导入Excel文件</button>
							</div>
						</div>
						<div class="table_scroll">
							<table class="display dataTables responsive table table-striped table-bordered table-hover dataTable s_h5_table">
								<thead>
									<tr>
										<th>类型</th>
										<th>产品名称</th>
										<th>物料编码</th>
										<th>录入人</th>
										<th>录入时间</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									<tr *ngFor="let row of tableData">
										<td>{{row.materielTypeStr?row.materielTypeStr:"--"}}</td>
										<td>{{row.productName}}</td>
										<td>{{row.materielNumber}}</td>
										<td>{{row.enterMan}}</td>
										<td>{{row.enterTime}}</td>
										<td>
											<button type="button" (click)="updata_domCode(row,addBomCodeModal)">编辑</button>
											<button type="button" (click)="del_domCode(row)">删除</button>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
						<div class="table-fix clearfix">
							<paginator [totalRecords]="totalCounts"
						           [rows]="pageSize"
						           [currentPage]="curPage - 1"
						           (onPageChange)="paginate($event)">
							</paginator>
							<button type="button" class="btn default refresh_btn" (click)="refresh()"><i class="fa fa-refresh"></i></button>
						</div>
					</div>
				</div>
			</div>
		</div>
	</sa-widgets-grid>
</div>
<!-- 添加编辑物料编码 -->
<section bsModal #addBomCodeModal="bs-modal" id="addBomCodeModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" >
	<div class="modal-dialog modal-lg">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" (click)="closeAddBomModal(addBomCodeModal)" aria-label="Close"><span
						aria-hidden="true">&times;</span></button>
				<h4 *ngIf="!material.id" class="modal-title">添加物料信息</h4>
				<h4 *ngIf="material.id" class="modal-title">编辑物料信息</h4>
			</div>
			<div class="modal-body">
				<form id="bomHoldFrom"  class="form-horizontal" role="form" novalidate="novalidate" [saBootstrapValidator]="validatorOptions">
				<div class="row form-horizontal">
					<div class="form-group clearfix">
						<label class="control-label col-sm-2 no-padding-right">物料类型<sup>*</sup></label>
						<div class="col-sm-9">
								<select class="form-control" name="type" [(ngModel)]='material.materielType' [disabled]="material.id?true:false" (change)="typeChange($event.target.value)" style="width: 100%">
									<option value="">请选择</option>
									<option *ngFor="let item of materialTypeList" [value]='item.materielType'>
										{{item.materielTypeName}}</option>
								</select>
						</div>
					</div>
					<div class="form-group clearfix">
						<label class="control-label col-sm-2 no-padding-right">产品名称<sup>*</sup></label>
						<div class="col-sm-9">
							<div class="clearfix">
								<!-- 这里的对象就是要添加往后台传的 -->
								<input class="form-control" name="productName"  [(ngModel)]='material.productName'  type="text"
									placeholder="填写产品名称" />
							</div>
						</div>
					</div>
					<div class="form-group clearfix">
						<label class="control-label col-sm-2 no-padding-right">物料编码<sup>*</sup></label>
						<div class="col-sm-9">
							<div class="clearfix">
								<!-- 这里的对象就是要添加往后台传的 -->
								<input class="form-control" name="materialCode"  [(ngModel)]='material.materielNumber'  type="text"
									placeholder="填写物料编码" />
							</div>
						</div>
					</div>
				</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" (click)="closeAddBomModal(addBomCodeModal)">取消</button>
				<button type="button" class="btn btn-primary" (click)="submitModal(addBomCodeModal)">提交</button>
			</div>
		</div>
	</div>
</section>
<!-- 添加BOM编码  结束 -->
<!-- 导入弹框 -->
<div bsModal #weightModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
	aria-hidden="true">
	<div class="modal-dialog modal-lg">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" (click)="cancelUp(weightModal)" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title">上传Excel文件</h4>
			</div>
			<div class="modal-body">

				<div class="row">
					<form class="form form-inline " role="form">

						<div class="row" style="margin-bottom: 24px;">
							<div class="form-group module_line">
								<button type="button" class="btn btn-primary" (click)="load_module()">下载模板</button>
								<span class="row" class="note">注：请先下载模板，采用模板编辑文件后上传</span>
							</div>
						</div>


						<div class="row">
							<!--<label class="control-label col-sm-1" for="imgFile" style="padding: 0;display: inline-block;line-height: 32px;">文件</label>-->
							<div class="col-sm-10" style="padding: 0;">
								<div class="clearfix module_line">
									<button type="button" class="btn btn-primary" style="width: 120px;">上传模板文件
										<input type="file" class="up" (change)="fileChange($event.target.files)"
											name="fileToUpload" (click)='clearFile()' [(ngModel)]='fileUp' type="file"
											placeholder='' />
									</button>
									<span class="row" class="note">注：格式excel</span>
								</div>
							</div>
						</div>
						<div *ngIf="fileToUpload">
							<label class="control-label col-sm-1"></label>
							<div>
								<ul>
									<li class="file_list"><i class="fa fa-file-text-o"
											style="margin-right: 12px;"></i>{{fileToUpload.name}}<i
											class="fa fa-check-circle green" style="margin-left: 60px;"></i></li>
								</ul>
							</div>
						</div>
					</form>
				</div>

			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" (click)="cancelUp(weightModal)">取消</button>
				<button type="button" class="btn btn-primary" (click)="submitData(weightModal)">确认</button>
			</div>
		</div>
	</div>
</div>
<!-- 导入弹框 结束 -->